{extend name="template/base" /}
{block name="content"}
<div class="page-container">

    <form class="mb-20" method="get" action="{:\\think\\Url::build($Request.action)}">
        <input type="text" class="input-text" style="width:250px" placeholder="商品名称" name="goods_name" value="{$Request.param.goods_name}">

        <select name="status" class="select-box" style="width: 200px;">
            <option value="">全部</option>
            <option value="1">已上架</option>
            <option value="0">已下架</option>
        </select>

        <button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
    </form>

    <div class="cl pd-5 bg-1 bk-gray">
        <span class="l">
            {tp:menu menu="add" /}
        </span>
        <span class="r pt-5 pr-5">
            共有数据 ：<strong>{$total ?? 0}</strong> 条
        </span>
    </div>
    <table class="table table-border table-bordered table-hover table-bg mt-20">
        <thead>
        <tr class="text-c">
            <!--<th></th>-->
            <th width="5%">id</th>
            <th width="10%">商品图片</th>
            <th width="20%">商品名称</th>
            <th width="5%">元/斤</th>
            <th width="5%">元/个</th>
            <th width="5%">状态</th>
            <th width="15%">操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="list" id="vo"}
            <tr class="text-c">
                <td>{$vo.goods_id}</td>
                <td><img src="__ROOT__/{$vo.pic??'#'}" width="100" height="80" alt="商品图片"></td>
                <td>{$vo.goods_name}</td>
                <td>{$vo.price}</td>
                <td>{$vo.price}</td>
                <td>
                    {if condition="$vo.status eq 0"}
                    <span class="label-danger radius ml-5 label">已下架</span>
                    {else}
                    <span class="label-success radius ml-5 label">售卖中</span>
                    {/if}
                </td>
                <td>
                    {if condition="$vo.status eq 0"}
                    <a class="label ml-5 radius label-success" href="javascript:;" onclick="setst('{$vo.goods_id}','{$vo.status}')">上架</a>
                    {else}
                    <a class="label ml-5 radius label-danger" href="javascript:;" onclick="setst('{$vo.goods_id}','{$vo.status}')">下架</a>
                    {/if}
                    <a class="label ml-5 radius label-primary" href="javascript:;" onclick="layer_open('修改分类','__URL__/update/id/{$vo.goods_id}')">修改</a>
                </td>
            </tr>
        {/volist}
        </tbody>
    </table>
    <div class="page-bootstrap">{$page??''}</div>
</div>
{/block}



{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script>

    // 删除分类
    function setst(id,st) {
        if(st==0){
            var msg = '上架';
        } else {
            var msg = '下架';
        }

        layer.confirm('确定要'+msg+'该商品吗？', {
            btn: ['确定', '取消'],
            title: '提示',
            icon: 3
        }, function () {
            url = "__URL__/setStatus";
            $.post(url, {id: id,status: st}, function (data) {
                if (data.code == 0) {
                    layer.msg(data.msg, {icon: 1, time: 1000});
                    window.location.reload();
                } else {
                    layer.alert(data.msg);
                }
            }, 'json')
        }, function (index) {
            layer.close(index);
        });

    }
</script>
{/block}
